import { reactive } from 'vue'

export const store = {
    state: reactive({
        token: '',
        account: 'guest',
        username: '游客',
        departmentId: '',
        departmentCode: '',
        departmentName: '',
        alerts: {
            taskMsg: '',
            taskNum: '',
            msg: '',
            msgNum: ''
        }
        // roles: ''
    }),

    setAccessToken(_value) {
        this.state.token = _value
    },

    setAccount(_value) {
        this.state.account = _value
    },

    setUserName(_value) {
        this.state.username = _value
    },

    setDepartmentId(_value) {
        this.state.departmentId = _value
    },

    setDepartmentCode(_value) {
        this.state.departmentCode = _value
    },

    setDepartmentName(_value) {
        this.state.departmentName = _value
    },

    setAlertsTask(_value) {
        this.state.alerts.taskNum = _value
        if (_value === 0) {
            this.state.alerts.taskMsg = '当前无待办任务'
        } else {
            this.state.alerts.taskMsg = '当前有' + _value + '条待办任务'
        }
    },

    setAlertsMsg(_value) {
        this.state.alerts.msgNum = _value
        console.log(_value)
        if (_value === 0) {
            this.state.alerts.msg = '当前无新消息'
        } else {
            this.state.alerts.msg = '当前有' + _value + '条新消息'
        }
    }
}
